package ace.cmp.easycaptcha.core.properties;

import ace.cmp.core.enums.BaseEnum;
import java.awt.*;
import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author caspar
 * @date 2023/3/21 15:17
 */
@ConfigurationProperties(prefix = EasyCaptchaProperties.CONFIG_PREFIX)
@Data
public class EasyCaptchaProperties {
  public static final String CONFIG_PREFIX = "ace.captcha.module.easy-captcha";

  /**
   * 宽度
   */
  private Integer width = 200;

  /**
   * 高度
   */
  private Integer height = 50;

  /**
   * 验证码长度
   */
  private Integer length = 4;

  /**
   * 算术验证码运算位数
   */
  private Integer arithmeticLength = 2;

  /**
   * 验证码类型 {@link CaptchaTypeEnum}
   */
  private CaptchaTypeEnum captchaType = CaptchaTypeEnum.DEFAULT_CAPTCHA;

  /**
   * 字体
   */
  private FontEnum font = FontEnum.FONT_1;

  /**
   * 验证码内容
   */
  private CaptchaCharTypeEnum captchaCharType = CaptchaCharTypeEnum.TYPE_ONLY_NUMBER;

  @Getter
  @AllArgsConstructor
  public static enum CaptchaTypeEnum implements BaseEnum<Integer> {
    DEFAULT_CAPTCHA(1, "标准验证码"),
    ARITHMETIC_CAPTCHA(2, "算术验证码"),
    CHINESE_CAPTCHA(3, "中文验证码"),
    ;
    private final Integer code;
    private final String desc;
  }

  @Getter
  @AllArgsConstructor
  public static enum CaptchaCharTypeEnum implements BaseEnum<Integer> {
    TYPE_DEFAULT(1, "数字和字母混合"),
    TYPE_ONLY_NUMBER(2, "纯数字"),
    TYPE_ONLY_CHAR(3, "纯字母"),
    TYPE_ONLY_UPPER(4, "纯大写字母"),
    TYPE_ONLY_LOWER(5, "纯小写字母"),
    TYPE_NUM_AND_UPPER(6, "数字和大写字母");
    private final Integer code;
    private final String desc;
  }

  @Getter
  @AllArgsConstructor
  public static enum FontEnum implements BaseEnum<Integer> {
    FONT_1(1, ""),
    FONT_2(2, ""),
    FONT_3(3, ""),
    FONT_4(4, ""),
    FONT_5(5, ""),
    FONT_6(6, ""),
    FONT_7(7, ""),
    FONT_8(8, ""),
    FONT_9(9, ""),
    FONT_10(10, ""),
    ;
    private final Integer code;
    private final String desc;
  }
}
